export default function translate(translations:any) {
  return (template:any, replacements:any)=>{
    replacements = replacements || {};
    template = translations[template] || template;
    return template.replace(/{([^}]+)}/g, (_:any, key:any)=>{
      let str = replacements[key];
      if (translations[replacements[key]] !== null && translations[replacements[key]] !== undefined) {
        str = translations[replacements[key]];
      }
      return str || '{' + key + '}';
    });
  };
}